//
//  WCNSubSettingVC.m
//  WCN
//
//  Created by wsj2015 on 16/4/7.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNSubSettingVC.h"
#import "WCNSettingItemController.h"
#import "WCNServiceTimePageVC.h"
//#import "ChatManager.h"
#import "WCNLoginVC.h"
#import "JCAlertView.h"
#import "WCNMyPrivateSettingVC.h"
#import "WCNIconLabelTCell.h"
#import "WCNAboutUsVC.h"

@interface WCNSubSettingVC ()


@property (nonatomic,  strong) NSArray *titleArray;

@end

@implementation WCNSubSettingVC


- (NSArray *)titleArray{
    if (!_titleArray) {
        _titleArray =@[@"服务设置",@"服务时间设置",@"隐私",@"关于",@"退出登录"];
    }
    return _titleArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"设置";
    self.tableView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
    [self.tableView registerNib:[UINib nibWithNibName:@"WCNIconLabelTCell" bundle:nil] forCellReuseIdentifier:@"WCNIconLabelTCell"];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.titleArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *imageArray =@[@"Me_Set",@"退出登录",@"icon_隐私",@"icon_隐私",@"退出登录"];
    WCNIconLabelTCell *cell =[tableView dequeueReusableCellWithIdentifier:@"WCNIconLabelTCell" forIndexPath:indexPath];
    cell.leftIcon.image = [UIImage imageNamed:imageArray[indexPath.row]];
    cell.iconTitle.text = self.titleArray[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
            
            [self.navigationController pushViewController:[WCNSettingItemController new] animated:YES];
            break;
        case 1:
            [self.navigationController pushViewController:[WCNServiceTimePageVC new] animated:YES];
            
            break;
        case 2:
            
         [self.navigationController pushViewController:[WCNMyPrivateSettingVC new] animated:YES];
            break;
        case 3:
//            [self logOut];
            [self.navigationController pushViewController:[ WCNAboutUsVC new] animated:YES];
          
            break;
        case 4:
            [self logOut];
            
            break;
           
        default:
            break;
    }
   
}
- (void)logOut{
    
    defineWeakSelf;
    [JCAlertView showTwoButtonsWithTitle:@"提示" Message:@"是否确定退出登录" ButtonType:1 ButtonTitle:@"否" Click:nil ButtonType:2 ButtonTitle:@"是" Click:^{
        //角标清零
        [[UIApplication sharedApplication]setApplicationIconBadgeNumber:0];
        [[WCDefaultManager shareMg] logout];
        //退出环信
//        [[ChatManager sharedChatManager] LogoffHuanxin];
        
        
        WCNLoginVC *loginVC = [[WCNLoginVC alloc] init];
        [weakSelf.navigationController setViewControllers:@[loginVC] animated:NO];
        
    }];
    
    
}

@end
